package mapper;

import entity.Customer;
import jakarta.annotation.ManagedBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

// 声明 MyBatis Mapper 接口
@Mapper
public interface CustomerMapper {

    // 客户新增 SQL（）
    @Insert("INSERT INTO customer (name,contact, phone , address,creat_time)  " +
            "VALUES(#{name},#{contect}, #{phone},  #{address},NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")   //mybatis要把数据库生成的主键返回到id中
    int insertCustomer(Customer customer);

    //客户修改
    int updateCustomer(Customer customer);



    //客户删除
    @Delete("DELETE FROM customer WHERE id = #{id}")
    int deleteById(Long id);

    //客户查询(查询客户的所有的信息）
    @Select("SELECT * FROM customer WHERE id = #{id}")
    Customer selectCustomerById(Long id);//返回Customer 可以直接封装返回的信息

    @Select("SELECT * FROM customer")     //查找所有的客户信息
    List<Customer> selectAllCustomer();

    @Select("SELECT * FROM customer WHERE name = #{name}")
    Customer selectCustomerByName(String name);


    //客户资料的导入导出
    void exportCustomer(List<Customer> customer);  //客户资料导出

    void importCustomer(List<Customer> customer);  //客户资料导入
}